<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('会员积分兑换订单列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="member-creditList-form">
                <input type="hidden" name="memberId" th:value="${memberId}"/>
                <div class="select-list">
                    <ul>
                        <li>
                            <p style="width: 110px">订单状态： </p>
                            <select name="orderStatus" th:with="type=${@dict.getType('exchange_status')}">
                                <option value="-1">全部</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li class="select-time">
                            <p style="width: 110px">兑换时间： </p>
                            <input type="text" class="time-input" placeholder="开始时间"
                                   name="params[beginTime]"/>
                            <span>-</span>
                            <input type="text" class="time-input" placeholder="结束时间"
                                   name="params[endTime]"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="btn-group-sm" id="toolbar" role="group">
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    const prefix = ctx + "back/shopOrder";
    const orderStatusDict = [[${@dict.getType('exchange_status')}]];
    const productTypeDict = [[${@dict.getType('product_type')}]];

    $(function () {
        var options = {
            url: prefix + "/searchCreditList",
            height: 600,
            modalName: "积分商城订单",
            sortName: "createTime",
            sortOrder: "desc",
            showColumns: false,
            columns: [
                {
                    field: 'orderSn',
                    title: '订单号',
                    sortable: true
                },
                {
                    field: 'memberSn',
                    title: '用户',
                    formatter: function (value, row, index) {
                        var actions = [];
                        let imgHtml = $.common.sprintf("<img class='img-circle img-xs' data-height='%s' data-width='%s' data-target='%s'  style='border-radius: 0;' src='%s'/>", 500, 'auto', 'self', row.avatar);
                        actions.push(imgHtml);
                        actions.push('<br/><span style="font-weight: bold">' + row.phone + '</span>');
                        return actions.join('');
                    }
                },
                {
                    field: 'productType',
                    title: '兑换商品类型',
                    sortable: true,
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(productTypeDict, value);
                    }
                },
                {
                    field: 'productName',
                    title: '兑换商品信息',
                    formatter: function (value, row, index) {
                        var actions = [];
                        let imgHtml = $.common.sprintf("<img class='img-circle img-xs' data-height='%s' data-width='%s' data-target='%s'  style='border-radius: 0;' src='%s'/>", 500, 'auto', 'self', row.productCoverUrl);
                        actions.push(imgHtml);
                        actions.push('<br/><span style="font-weight: bold">' + value + '</span>');
                        return actions.join('');
                    }
                },
                {
                    field: 'payCost',
                    title: '兑换扣除积分',
                    sortable: true
                },
                {
                    field: 'orderStatus',
                    title: '订单状态',
                    sortable: true,
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(orderStatusDict, value);
                    }
                },
                {
                    field: 'exchangeCode',
                    title: '1',
                    visible:false
                },
                {
                    field: 'createTime',
                    title: '兑换时间',
                    sortable: true
                },
                {
                    field: 'completeTime',
                    title: '核销时间',
                    sortable: true
                }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>